package com.deneme.ozveri.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.deneme.ozveri.admin.AdminActivity;
import com.deneme.ozverimenu.R;

public class LoginScreenActivity extends Activity{
	private EditText username;
	private EditText password;
	private Button loginButton;
	private Button signUpButton;
	private TextView anonymous;
	
	private loginClickListener listener;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);
		
		username = (EditText) findViewById(R.id.login_username_edit);
		password = (EditText) findViewById(R.id.login_password_edit);
		loginButton =(Button) findViewById(R.id.login_login_button);
		signUpButton =(Button) findViewById(R.id.login_signup_button);
		anonymous=(TextView) findViewById(R.id.login_loginwithoutsignup_button);
		
		listener = new loginClickListener();
		
		loginButton.setOnClickListener(listener);
		signUpButton.setOnClickListener(listener);
		anonymous.setOnClickListener(listener);
		
		
		this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
		

		
	}
	
	private class loginClickListener implements OnClickListener{
		


		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.login_login_button:
					if(username.getText().toString().equals("admin")
							&& password.getText().toString().equals("12345") )
					{
						Intent intent = new Intent(LoginScreenActivity.this, AdminActivity.class);
						startActivityForResult(intent,0);
					}
					else
					{
						Intent intent = new Intent(LoginScreenActivity.this, FrameMenuAlphaActivity.class);
						startActivityForResult(intent,0);
					}
				break;
			case R.id.login_loginwithoutsignup_button:
				Intent intent = new Intent(LoginScreenActivity.this, FrameMenuAlphaActivity.class);
				startActivityForResult(intent,0);
				break;

			default:
				break;
			}
			
		}
		
	}

}
